Add parallel agent group telemetry for tracking parallel agent execution HUD-581#290
Add parallel agent group telemetry for tracking parallel agent execution HUD-581#290
Conversation
- Add `parallel_agent_group` context manager for grouping parallel agent runs - Add `trace_subagent` function for tracing individual subagent execution - Export new telemetry functions from hud module and hud.telemetry - Update agent tool to support optional trace_id parameter - Add comprehensive tests for parallel group telemetry - Document new telemetry features in tools reference
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dffa3ff737
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return ToolResult( | ||
| content=[TextContent(type="text", text=content)], | ||
| meta={"trace_id": trace_id} if trace_id else None, |
There was a problem hiding this comment.
Avoid returning trace_id when no sub-trace is created
Because run_eval() always assigns ctx.trace_id even when trace=False, the unconditional meta={"trace_id": trace_id} here means callers get a trace_id even when trace_subagent=False (default) and no sub-trace is requested. This contradicts the new docs and can mislead clients into linking to a non-existent or unintended trace. Consider only propagating trace_id (or setting it from ctx) when should_trace/trace_subagent (or explicitly when using the parent trace) so meta is present only when an actual trace is expected.
Useful? React with 👍 / 👎.
ryantzr1
left a comment
There was a problem hiding this comment.
HUD Bugbot Review
Found critical timestamp bug in parallel group telemetry that prevents progress tracking, plus trace_id handling issues in AgentTool.
|
|
||
| now = _now_iso() | ||
| end_time = now if final else self._start_time | ||
|
|
There was a problem hiding this comment.
Incorrect end_time in non-final spans causes timestamps to not advance
High Severity
In _build_span(), when final=False, the end_time is set to self._start_time instead of the current time (now). This means all intermediate update spans will have the same start and end time, making them appear as zero-duration spans. This will prevent proper progress visualization in the UI and could cause issues with span ordering and deduplication logic.
The line should be: end_time = now (not conditional on final).
Suggestion: Change line 181 from end_time = now if final else self._start_time to end_time = now to ensure all spans show elapsed time.
- Always use current time for end_time in parallel group telemetry events instead of conditionally using start_time for non-final events - Only update trace_id from ctx when creating a new trace, preserving parent trace_id when use_parent_trace=True for hierarchical agents
Note
Adds real-time telemetry for parallel agent execution and refines subagent tracing behavior.
hud.telemetry.parallel_groupwithParallelAgentGroup,ParallelAgentInfo, andparallel_agent_group(...)context manager that emitsparallel-agent-groupspans; exported viahud.telemetryandhudroottrace_subagentoption; when enabled creates a new trace per subagent call, includes sub-trace inToolResult.meta["trace_id"], and propagatestrace_idon exceptions; preserves parent trace when nested unless overriddendocs/reference/tools.mdxto documenttrace_subagentandtrace_idin resultsWritten by Cursor Bugbot for commit 356ec78. This will update automatically on new commits. Configure here.